package com.bytedance.common.a;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;

import java.util.regex.Pattern;

final class i {
    private static Pattern a;

    static {
        i.a = Pattern.compile("^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$");
    }

    static boolean a(Context arg2) {
        boolean v0 = true;
        int v1 = i.b(arg2);
        if (v1 != 1 && v1 != 0) {
            v0 = false;
        }

        return v0;
    }

    static boolean a(String arg6) {
        boolean v0 = false;
        if (arg6 != null) {
            char[] v2 = arg6.toCharArray();
            if (v2.length > 0 && v2.length <= 255) {
                int v3 = v2.length;
                int v1;
                for (v1 = 0; v1 < v3; ++v1) {
                    int v4 = v2[v1];
                    if ((v4 < 65 || v4 > 90) && (v4 < 97 || v4 > 122) && (v4 < 48 || v4 > 57) && v4 != 46 && v4 != 45) {
                        return v0;
                    }
                }

                v0 = true;
            }
        }

        return v0;
    }

    static boolean b(String arg2) {
        boolean v0 = arg2 == null || arg2.length() < 7 || arg2.length() > 15 || (arg2.equals("")) || !i.a.matcher(((CharSequence) arg2)).matches() ? false : true;
        return v0;
    }

    static int b(Context arg2) {

        try {
            NetworkInfo v0_1 = ((ConnectivityManager) arg2.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
            if (v0_1 != null && (v0_1.isAvailable())) {
                int v0_2 = v0_1.getType();
                return v0_2;
            }
        } catch (Throwable v0) {
            return -2;
        }

        return -1;
    }

    static String c(Context arg3) {
        String v0_1;
        try {
            v0_1 = ((WifiManager) arg3.getSystemService(Context.WIFI_SERVICE)).getConnectionInfo().getBSSID();
        } catch (Throwable v0) {
            HttpDns.a("failed to get BSSID: " + v0);
            v0_1 = null;
        }

        return v0_1;
    }
}

